<template>
  <div class="profile-container">
    <!-- 顶部导航栏 -->
    <div class="navbar glass-effect">
      <div class="navbar-content">
        <div class="brand">
          <svg viewBox="0 0 40 40" class="brand-logo">
            <defs>
              <linearGradient id="logoGradient" x1="0%" y1="0%" x2="100%" y2="100%">
                <stop offset="0%" style="stop-color:#ec4899;stop-opacity:1" />
                <stop offset="50%" style="stop-color:#d946ef;stop-opacity:1" />
                <stop offset="100%" style="stop-color:#8b5cf6;stop-opacity:1" />
              </linearGradient>
            </defs>
            <path d="M20 4 L36 12 L36 28 L20 36 L4 28 L4 12 Z" 
                  fill="url(#logoGradient)" stroke="white" stroke-width="1"/>
            <circle cx="20" cy="16" r="3" fill="white"/>
            <rect x="17" y="20" width="6" height="12" rx="1" fill="white"/>
          </svg>
          <h1 class="brand-name gradient-text">我的</h1>
        </div>
      </div>
    </div>

    <!-- 主内容区域 -->
    <div class="main-content">
      <!-- 用户信息卡片 -->
      <div class="user-card glass-effect">
        <div class="user-avatar">
          <el-icon :size="60"><Avatar /></el-icon>
        </div>
        <h2 class="user-name">{{ authStore.user?.username || '用户' }}</h2>
        <p class="user-email">{{ authStore.user?.email || '' }}</p>
      </div>

      <!-- 功能菜单 -->
      <div class="menu-section">
        <div class="menu-group">
          <div class="menu-item" @click="$router.push('/tryon')">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><MagicStick /></el-icon>
              <span class="menu-item-text">智能试衣</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
          
          <div class="menu-item" @click="$router.push('/wardrobe')">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><Suitcase /></el-icon>
              <span class="menu-item-text">我的衣橱</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
          
          <div class="menu-item" @click="$router.push('/history')">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><Clock /></el-icon>
              <span class="menu-item-text">历史记录</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
        </div>

        <div class="menu-group">
          <div class="menu-item">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><Setting /></el-icon>
              <span class="menu-item-text">设置</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
          
          <div class="menu-item">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><QuestionFilled /></el-icon>
              <span class="menu-item-text">帮助与反馈</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
        </div>

        <div class="menu-group">
          <div class="menu-item menu-item-danger" @click="handleLogout">
            <div class="menu-item-left">
              <el-icon class="menu-item-icon" :size="20"><SwitchButton /></el-icon>
              <span class="menu-item-text">退出登录</span>
            </div>
            <el-icon class="menu-item-arrow"><ArrowRight /></el-icon>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部导航 -->
    <BottomNav />
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { 
  Avatar, 
  MagicStick, 
  Suitcase, 
  Clock, 
  Setting, 
  QuestionFilled, 
  SwitchButton,
  ArrowRight
} from '@element-plus/icons-vue'
import { useAuthStore } from '@/stores/auth'
import BottomNav from '@/components/BottomNav.vue'

const router = useRouter()
const authStore = useAuthStore()

const handleLogout = async () => {
  try {
    await ElMessageBox.confirm(
      '确定要退出登录吗？',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    authStore.logout()
    router.push('/login')
  } catch {
    // 用户取消
  }
}
</script>

<style scoped>
.profile-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #fdf2f8 0%, #fae8ff 50%, #f3e8ff 100%);
}

/* 导航栏 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(217, 70, 239, 0.1);
  box-shadow: 0 4px 20px rgba(217, 70, 239, 0.08);
}

.navbar-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
}

.brand-name {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
}

.gradient-text {
  background: linear-gradient(135deg, #ec4899 0%, #d946ef 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 主内容区域 */
.main-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1rem 100px;
}

/* 用户信息卡片 */
.user-card {
  background: white;
  border-radius: 24px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 10px 40px rgba(217, 70, 239, 0.1);
  margin-bottom: 2rem;
}

.user-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899 0%, #d946ef 50%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin: 0 auto 1rem;
}

.user-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.5rem;
}

.user-email {
  font-size: 0.875rem;
  color: #6b7280;
  margin: 0;
}

/* 菜单区域 */
.menu-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-group {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(217, 70, 239, 0.08);
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 1px solid #f3f4f6;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.05) 0%, rgba(217, 70, 239, 0.05) 100%);
}

.menu-item:active {
  transform: scale(0.98);
}

.menu-item-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-item-icon {
  color: #d946ef;
}

.menu-item-text {
  font-size: 1rem;
  font-weight: 500;
  color: #1f2937;
}

.menu-item-arrow {
  color: #9ca3af;
  font-size: 16px;
}

.menu-item-danger .menu-item-icon {
  color: #ef4444;
}

.menu-item-danger .menu-item-text {
  color: #ef4444;
}

/* 移动端优化 */
@media (max-width: 768px) {
  .navbar-content {
    padding: 1rem;
  }
  
  .main-content {
    padding: 1.5rem 1rem 100px;
  }
  
  .user-card {
    padding: 1.5rem;
  }
  
  .user-avatar {
    width: 80px;
    height: 80px;
  }
  
  .user-name {
    font-size: 1.25rem;
  }
}
</style>

